package com.hghivln.blog.controller;


import com.hghivln.blog.common.lang.Result;
import com.hghivln.blog.entity.Tag;
import com.hghivln.blog.pojo.vo.HotTagVo;
import com.hghivln.blog.service.TagService;
import com.hghivln.blog.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 标签表 前端控制器
 * </p>
 *
 * @author hghivln
 * @since 2021-09-11
 */
@RestController
@RequestMapping("/tag")
public class TagController {
    @Autowired
    private TagService TagService;

    /**
     * 根据名称搜索标签
     */
    @GetMapping("/searchByName/{name}")
    public Result<List<Tag>> searchByName(@PathVariable String name) {
        List<Tag>  list =TagService.searchByName(name);
        return new Result<>(list);
    }

    /**
     * 根据博客id查询
     */
    @GetMapping("/getByBlogId/{id}")
    public Result<List<Tag>> getByBlogId(@PathVariable Long id) {
        List<Tag> list = TagService.getByBlogId(id);
        return new Result<>(list);
    }

    /**
     * 获取热门标签
     */
    @GetMapping("/getHotTag")
    public Result<?> getHotTag() {
        List<HotTagVo> list = TagService.getHotTag();
        return new Result<>(list);
    }
}
